package thinking.函数高级

object 偏函数简写 {
  def main(args: Array[String]): Unit = {
    val value = List(1, 2, 3, 4, "hello")

    //初步简写
    def f2: PartialFunction[Any, Int] = {
      case i: Int => i + 1
    }

    val value1 = value.collect(f2)
    print(value1)

    //继续简写
    val value2 = value.collect {
      case i: Int => i + 1
    }
    println(value2)
  }

}
